package cc.md888;

import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.TemplateType;


// 演示例子，执行 main 方法控制台输入模块表名回车自动生成对应项目目录中
public class AppGenerator {



    public static void main(String[] args) {

        FastAutoGenerator.create("jdbc:mysql://localhost:3306/toolkit?serverTimezone=Asia/Shanghai&characterEncoding=UTF-8&useSSL=false",
                "root", "123456")
                .globalConfig(builder -> {
                    builder.author("maodou") // 设置作者
                            .commentDate("yyyy-MM-dd HH:mm:ss")
//                            .fileOverride() // 覆盖已生成文件
                            .outputDir("G:\\dev\\toolkit-backend\\toolkit-app\\src\\main\\java"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent( "cc.md888.app") ;// 设置父包名
                    builder.mapper("infr.dao.mapper");
                    builder.xml("infr.dao.mapper.xml");
                    builder.service("infr.dao");
                    builder.serviceImpl("infr.dao.impl");
                    builder.entity("domain.entity");
                })
                .strategyConfig(builder -> {
                    builder // 设置需要生成的表名
                            .addInclude("activate_code", "user", "option", "feedback");

                    builder.entityBuilder()
                            .enableColumnConstant()
                            .enableLombok();
//                            .disableSerialVersionUID()

                    builder.serviceBuilder()
                            .formatServiceImplFileName("%sDaoImpl")
                            .formatServiceFileName("%sDao");
                })
                .templateConfig(builder -> builder.disable(TemplateType.CONTROLLER))
                .execute();
    }

}